package com.hsd.znsh.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.hsd.znsh.hql.Equal;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.NumberFormat;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/*
 * @auther: wangjiacai
 *
 * @create: 2018-04-09 10:54:54
 */
@Data
@Entity
@Table(name ="tbl_sensor")
public class Sensor {

    /*主键*/
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    /*名称*/
    @NotBlank(message = "传感器名称不能为空")
    private String name;

    /*别名*/
    private String alias;

    /*设备编号*/
    @NotBlank(message = "传感器SN不能为空")
    private String sensorSn;

    /*设备类别id*/
    @NotNull(message = "类别不能为空")
    private Integer sensorTypeId;

    /*主机id*/
    @NotNull(message = "基地不能为空")
    private Integer hostId;

    /*创建人id*/
    private Integer createUserId;

    /*在线状态*/
    private Integer onlineStatus;

    /*基地的具体逻辑位置*/
    @NotBlank(message = "传感器安装位置不能为空")
    private String position;

    /*物理位置经度*/
    @NotNull(message = "传感器GPS位置不能为空")
    private Double longitude;

    /*物理位置纬度*/
    @NotNull(message = "传感器GPS位置不能为空")
    private Double latitude;

    @NotNull(message = "传感器发送频率不能为空")
    private Integer frequency;

    private String fogId;

    /*当前数据最新时间*/
    @CreationTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date time;

}
